from math import *
from collections import deque
from copy import deepcopy
import sys
def inp(): return sys.stdin.readline().rstrip("\r\n") def multi(): return map(int, input().split())
def strmulti(): return map(str, inp().split())
def lis(): return list(map(int, inp().split()))
def lcm(a, b): return (a * b) // gcd(a, b)
def ncr(n, r): return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))
def stringlis(): return list(map(str, inp().split()))
def out(var): sys.stdout.write(str(var)) def printlist(a):
print(' '.join(str(a[i]) for i in range(len(a))))
def isPrime(n):
if (n <= 1): return False
if (n <= 3): return True
if (n % 2 == 0 or n % 3 == 0): return False
i = 5
while (i * i <= n):
if (n % i == 0 or n % (i + 2) == 0):
return False
i = i + 6
return True
def google():
t = int(inp())
for T in range(t):
print("Case #" + str(T + 1) + ": ", end="")
solve()
def normal(x):
if(x==0):
t = int(inp())
else:
t=1
for T in range(t):
solve()
def solve():
x,y = map(int,input().split())
if(x==0 and y==0):
print(0)
elif((x**2+y**2)**(0.5)==floor((x**2+y**2)**(0.5))):
print(1)
else:
print(2)
return
normal(0)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll t;
cin>>t;
while(t--){
float a, b;
cin>>a>>b;
if(a== 0 && b== 0){
cout<<0<<endl;
continue;
}
float x= (a*a)+ (b*b);
ll y= x;
x= sqrt(x);
y= sqrt(y);
if(x== y){
cout<<1<<endl;
}
else{
cout<<2<<endl;
}
}
return 0;
}
MATCHES Playing with Matches | HRDSEQ Hard Sequence |
DRCHEF Doctor Chef | 559. Maximum Depth of N-ary Tree |
821. Shortest Distance to a Character | 1441. Build an Array With Stack Operations |
1356. Sort Integers by The Number of 1 Bits | 922. Sort Array By Parity II |
344. Reverse String | 1047. Remove All Adjacent Duplicates In String |
977. Squares of a Sorted Array | 852. Peak Index in a Mountain Array |
461. Hamming Distance | 1748. Sum of Unique Elements |
897. Increasing Order Search Tree | 905. Sort Array By Parity |
1351. Count Negative Numbers in a Sorted Matrix | 617. Merge Two Binary Trees |
1450. Number of Students Doing Homework at a Given Time | 700. Search in a Binary Search Tree |
590. N-ary Tree Postorder Traversal | 589. N-ary Tree Preorder Traversal |
1299. Replace Elements with Greatest Element on Right Side | 1768. Merge Strings Alternately |
561. Array Partition I | 1374. Generate a String With Characters That Have Odd Counts |
1822. Sign of the Product of an Array | 1464. Maximum Product of Two Elements in an Array |
1323. Maximum 69 Number | 832. Flipping an Image |